﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace SCRUM.Core.BusinessObjects
{
    /// <summary>
    /// Represents state of a object. 
    /// </summary>
    [Serializable()]
    public class State : BusinessObject
    {
        /// <summary>
        /// All available Types of any item with state stored in SCRUM agenda
        /// </summary>
        public enum StateTypes
        {
            /// <summary>
            /// Project (associated database table = PROJECT_STATE)
            /// </summary>
            Project,
            /// <summary>
            /// Sprint (associated database table = SPRINT_STATE)
            /// </summary>
            Sprint,
            /// <summary>
            /// User Story (associated table = ?!?)
            /// </summary>
            User_Story,
            /// <summary>
            /// Backlog Item (associated database table = BLI_STATE)
            /// </summary>
            Bli,
            /// <summary>
            /// Task (associated database table = TASK_STATE)
            /// </summary>
            Task
        }

        /// <summary>
        /// Logical name of state
        /// </summary>
        public String Name { get; set; }

        /// <summary>
        /// Specifies what kind of state it is. Fe. Project state, Release state ...
        /// According to this param you will choose table to select states from.
        /// </summary>
        public StateTypes Type;

        /// <summary>
        /// Constructor for states of objects
        /// </summary>
        /// <param name="id">Identifier</param>
        /// <param name="name">Logical name</param>
        /// <param name="type">Type of states</param>
        public State(int id, String name, StateTypes type)
            :base(id)
        {
            this.Name = this.LocalizeString(type.ToString()+"State", name);
            this.Type = type;
        }

        /// <summary>
        /// Gets the default state for type
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public static State DefaultState(StateTypes type)
        {
            return DAO.DAOState.GetStateForType(1, type);
        }

        /// <summary>
        /// When toString called, name should be returned
        /// </summary>
        /// <returns>State name</returns>
        public override string ToString()
        {
            return this.Name;
        }
    }
}
